/*     */ package com.qmsk.business.manage.menu.controller;
/*     */ 
/*     */ import com.qmsk.business.manage.menu.dao.MenuDAO;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"wx/menu"})
/*     */ public class MenuController
/*     */ {
/*  32 */   private static final Logger logger = Logger.getLogger(MenuController.class);
/*     */ 
/*     */   @Autowired
/*     */   private MenuDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/all"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/*  50 */       Long shopId = RequestUtils.getLong(request, "shopId");
/*  51 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(shopId);
/*  52 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  54 */       logger.error(e);
/*  55 */       ResponseUtils.setErrorMsgResponse(
/*  56 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/id/{id}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  73 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  75 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(id, nPageIdx, nPageSize);
/*  76 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  78 */       logger.error(e);
/*  79 */       ResponseUtils.setErrorMsgResponse(
/*  80 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/*  97 */       int nResult = 0;
/*  98 */       Long id = null;
/*  99 */       String sData = RequestUtils.getStringOfData(request);
/* 100 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 101 */       if (p != null) {
/* 102 */         nResult = this.dao.applyUpdates(p);
/* 103 */         if (nResult > 0) {
/* 104 */           id = this.dao.getLastId();
/* 105 */           DbConnection.commit();
/*     */         } else {
/* 107 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 110 */       if (id != null) {
/* 111 */         String[] heads = { "id" };
/* 112 */         Object[] datas = { id };
/* 113 */         ResponseUtils.toGsonEbRst(heads, datas, response);
/* 114 */         return; }
/* 115 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 116 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 117 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 120 */       logger.error(e);
/* 121 */       DbConnection.rollback();
/* 122 */       ResponseUtils.setErrorMsgResponse(
/* 123 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 124 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 140 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 142 */       String[] strParams = id.split(",");
/* 143 */       int nResult = this.dao.deleteParams(strParams);
/* 144 */       DbConnection.commit();
/* 145 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 146 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 147 */         response);
/*     */     } catch (Exception e) {
/* 149 */       DbConnection.rollback();
/* 150 */       logger.error(e);
/* 151 */       ResponseUtils.setErrorMsgResponse(
/* 152 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 153 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 169 */     String sData = RequestUtils.getStringOfData(request);
/*     */     try {
/* 171 */       int nResult = 0;
/* 172 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 173 */       if (p != null) {
/* 174 */         nResult = this.dao.applyUpdates(p);
/* 175 */         if (nResult > 0)
/* 176 */           DbConnection.commit();
/*     */         else {
/* 178 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 181 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 182 */         RequestUtils.getSqlUpdateErrorMessage(sData, request), 
/* 183 */         response);
/*     */     } catch (Exception e) {
/* 185 */       DbConnection.rollback();
/* 186 */       logger.error(e);
/* 187 */       ResponseUtils.setErrorMsgResponse(
/* 188 */         RequestUtils.getSqlUpdateErrorMessage(sData, request) + ":" + 
/* 189 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.manage.menu.controller.MenuController
 * JD-Core Version:    0.5.3
 */